package cn.com.landsky.camera.common.hikvision;

import cn.com.landsky.camera.common.enums.ICommonEnum;
import lombok.Getter;

/***
 ** @category 请用一句话来描述其用途...
 ** @author qing.yunhui
 ** @email: qingyunhui@landsky.cn
 ** @createTime:2019-01-04 18:02
 **/
public class HikvisionEnums {

    /**
     * 码流类型(0:主码流 1:子码流 参数不填，默认为主码流)
     * */
    @Getter
    public enum STREAM_TYPE implements ICommonEnum{
        MAIN_STREAM(0,"主码流"),
        SUBBIT_STREAM(1,"子码流");
        private Integer code;
        private String value;
        STREAM_TYPE(Integer code,String value){
            this.code=code;
            this.value=value;
        }
        @Override
        public String getKey() {
            return code+"";
        }
    }

    /**
     * 取流协议(“rtsp”:RTSP协议 “rtmp”:RTMP协议 “hls”:HLS协议 参数不填，默认为RTSP协议)
     * */
    @Getter
    public enum PROTOCOL implements ICommonEnum{
        RTSP("rtsp","RTSP协议"),
        RTMP("rtmp","RTMP协议"),
        HLS("hls","HLS协议");
        private String key;
        private String value;
        PROTOCOL(String key,String value){
            this.key=key;
            this.value=value;
        }
        @Override
        public Integer getCode() {
            return null;
        }
    }

    /**
     * 传输协议(0:UDP，1:TCP，默认是TCP。注：EHOME设备回放只支持TCP传输，GB28181 2011及以前版本只支持UDP传输)
     * */
    @Getter
    public enum TRANS_MODE implements ICommonEnum{
        UDP(0,"UDP"),
        TCP(1,"TCP");
        private Integer code;
        private String value;
        TRANS_MODE(Integer code,String value){
            this.code=code;
            this.value=value;
        }
        @Override
        public String getKey() {
            return code+"";
        }
    }

    /**
     * 存储类型(0：中心存储 1：设备存储 默认为中心存储)
     * */
    @Getter
    public enum RECORD_LOCATION implements ICommonEnum{
        CENTRAL_STORAGE(0,"中心存储"),
        DEVICE_STORAGE(1,"设备存储");
        private Integer code;
        private String value;
        RECORD_LOCATION(Integer code,String value){
            this.code=code;
            this.value=value;
        }
        @Override
        public String getKey() {
            return code+"";
        }
    }

    /**
     * 开始或停止操作(0-开始 1-停止)
     * */
    @Getter
    public enum ACTION implements ICommonEnum{
        START(0,"开始"),
        STOP(1,"停止");
        private Integer code;
        private String value;
        ACTION(Integer code,String value){
            this.code=code;
            this.value=value;
        }
        @Override
        public String getKey() {
            return code+"";
        }
    }

    /**
     * 控制命令(不区分大小写 说明：
     *   LEFT 左转 RIGHT 右转 UP 上转 DOWN 下转 ZOOM_IN 焦距变大 ZOOM_OUT 焦距变小
     *   LEFT_UP 左上 LEFT_DOWN 左下 RIGHT_UP 右上 RIGHT_DOWN 右下 FOCUS_NEAR 焦点前移
     *   FOCUS_FAR 焦点后移 IRIS_ENLARGE 光圈扩大 IRIS_REDUCE 光圈缩小
     *   以下命令presetIndex 不可 为空： GOTO_PRESET 到预置点)
     * */
    @Getter
    public enum COMMAND implements ICommonEnum{
        LEFT("LEFT","左转"),
        RIGHT("RIGHT","右转"),
        UP("UP","上转"),
        DOWN("DOWN","下转"),
        ZOOM_IN("ZOOM_IN","焦距变大"),
        ZOOM_OUT("ZOOM_OUT","焦距变小"),
        LEFT_UP("LEFT_UP","左上"),
        LEFT_DOWN("LEFT_DOWN","左下"),
        RIGHT_UP("RIGHT_UP","右上"),
        RIGHT_DOWN("RIGHT_DOWN","右下"),
        FOCUS_NEAR("FOCUS_NEAR","焦距前移"),
        FOCUS_FAR("FOCUS_FAR","焦距后移"),
        IRIS_ENLARGE("IRIS_ENLARGE","光圈扩大"),
        IRIS_REDUCE("IRIS_REDUCE","光圈缩小"),
        /** 控制命令-选择为GOTO_PRESET时，参数 presetIndex 不可能空*/
        GOTO_PRESET("GOTO_PRESET","到预置点");
        private String key;
        private String value;
        COMMAND(String key,String value){
            this.key=key;
            this.value=value;
        }
        @Override
        public Integer getCode() {
            return null;
        }
    }

    /**
     * 云台速度(取值范围为1-100，默认50)
     * */
    @Getter
    public enum SPEED implements ICommonEnum{
        MIN_SPEED(1,"最小速度"),
        MAX_SPEED(100,"最大速度"),
        DEFAULT_SPEED(50,"默认速度");
        private Integer code;
        private String value;
        SPEED(Integer code,String value){
            this.code=code;
            this.value=value;
        }
        @Override
        public String getKey() {
            return code+"";
        }
        /**
         * 校验输入的speed是否合法
         * */
        public static boolean checkSpeed(int speed){
            if(speed>=MIN_SPEED.getCode().intValue() && speed<=MAX_SPEED.getCode().intValue()){
                return true;
            }
            throw new RuntimeException("传入的云台速度:"+speed+"，不合法!");
        }
    }

    /**海康 api url */
    @Getter
    public enum INTERFACE_URL implements ICommonEnum{
        //================================ 视频服务 ============================================
        REGIONS("/api/resource/v1/regions","分页获取区域列表"),
        PREVIEW_URL("/api/video/v1/cameras/previewURLs","获取监控点预览取流URL"),
        PLAYBACK_URL("/api/video/v1/cameras/playbackURLs","获取监控点回放取流URL"),
        CONTROLLING("/api/video/v1/ptzs/controlling","根据监控点编号进行云台操作"),
        //================================ 事件服务 ============================================
        EVENT_SUBSCRIPTION_BY_EVENT_TYPES("/api/eventService/v1/eventSubscriptionByEventTypes","按事件类型订阅事件"),
        EVENT_UN_SUBSCRIPTION_BY_EVENT_TYPES("/api/eventService/v1/eventUnSubscriptionByEventTypes","按事件类型取消订阅"),
        EVENT_SUBSCRIPTION_VIEW("/api/eventService/v1/eventSubscriptionView","按用户查询事件订阅信息");
        private String key;
        private String value;
        INTERFACE_URL(String key,String value){
            this.key=key;
            this.value=value;
        }
        @Override
        public Integer getCode() {
            return null;
        }

    }


}
